//
//  UserIntroductionCell.m
//  ChatForHot
//
//  Created by FLY on 2018/10/14.
//  Copyright © 2018年 FLY. All rights reserved.
//

#import "UserIntroductionCell.h"

@implementation UserIntroductionCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self.contentView addSubview:self.HOTCHATsignImgView];
        [self.contentView addSubview:self.HOTCHATsignLb];
        [self.contentView addSubview:self.HOTCHATsignContent];
        [self.contentView addSubview:self.HOTCHATlineView];
        
        [self.HOTCHATsignImgView mas_updateConstraints:^(MASConstraintMaker *make) {
            
            make.left.top.equalTo(self.contentView).mas_offset(15);
            make.height.width.mas_equalTo(17);
            
        }];
        [self.HOTCHATsignLb mas_updateConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(self.HOTCHATsignImgView.mas_right).mas_offset(10);
            make.centerY.equalTo(self.HOTCHATsignImgView.mas_centerY);
        }];
        [self.HOTCHATsignContent mas_updateConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(self.HOTCHATsignLb.mas_left);
            make.right.equalTo(self.contentView.mas_right).mas_offset(-15);
            make.top.equalTo(self.HOTCHATsignImgView.mas_bottom).mas_offset(3);
        }];
        [self.HOTCHATlineView mas_updateConstraints:^(MASConstraintMaker *make) {
            
            make.bottom.equalTo(self.contentView);
            make.left.right.equalTo(self.contentView);
            make.height.mas_equalTo(0.5);
        }];
  
    }
    
    return self;
}
- (void)setModel:(UserInfoModel *)model{
    
    _model = model;
    
    if (model) {
        
        NSString *signStr = [NSString stringWithFormat:@"%@",model.signature];
        
        if (signStr.length ==  0) {
            
            signStr = NSLocalizedString(@"StrN041", nil);;
        }
        
        self.HOTCHATsignContent.text = signStr;
        
    }
    
    
}
+ (CGFloat)HOTCHATcaculateCellHeightWithModel:(UserInfoModel *)model{
    if (model.signature == nil || model.signature.length == 0) {
        
        return 62;
    }
    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:model.signature];
    text.font = [UIFont systemFontOfSize:12.0];
    text.lineSpacing = 3;
    YYTextContainer *container = [YYTextContainer containerWithSize:CGSizeMake(kScreenWidth -70 , MAXFLOAT)];
    container.maximumNumberOfRows = 0;
    YYTextLayout *textLayout = [YYTextLayout layoutWithContainer:container text:text];
    return textLayout.textBoundingSize.height + 50;
}
//lzzy
- (UIImageView *)HOTCHATsignImgView{
    
    if (_HOTCHATsignImgView == nil) {
        
        _HOTCHATsignImgView = [[UIImageView alloc]init];
        _HOTCHATsignImgView.image = [UIImage imageNamed:@"all_personal_intro"];
    }
    return _HOTCHATsignImgView;
}
- (UILabel *)HOTCHATsignLb{
    
    if (_HOTCHATsignLb == nil) {
        
        _HOTCHATsignLb = [[UILabel alloc]init];
        _HOTCHATsignLb.textColor = HOTCHATHexColor(0x444444);
        _HOTCHATsignLb.font = [UIFont systemFontOfSize:14];
        _HOTCHATsignLb.text = NSLocalizedString(@"StrN039", nil);
        
    }
    return _HOTCHATsignLb;
}
- (UILabel *)HOTCHATsignContent{
    
    if (_HOTCHATsignContent == nil) {
        
        _HOTCHATsignContent = [[UILabel alloc]init];
        _HOTCHATsignContent.textColor = HOTCHATHexColor(0x979797);
        _HOTCHATsignContent.font = [UIFont systemFontOfSize:12];
        _HOTCHATsignContent.numberOfLines = 0;
        
    }
    return _HOTCHATsignContent;
}
- (UIView *)HOTCHATlineView{
    
    if (_HOTCHATlineView == nil) {
        
        _HOTCHATlineView = [[UIView alloc]init];
        _HOTCHATlineView.backgroundColor = HOTCHATHexColor(0xF0F0F0);
    }
    return _HOTCHATlineView;
}
@end
